#!/bin/bash
ps -ef|grep "jd consumption"|awk '{print $2}'|xargs kill -9
ps -ef|grep "taobao consumption"|awk '{print $2}'|xargs kill -9
ps -ef|grep "autopush consumption"|awk '{print $2}'|xargs kill -9

while true
do
    sleep 5
    #b2c数据抓取
    PRO_NOW=`ps -ef | grep "shguan consumption" | wc -l`

    if [ $PRO_NOW -lt 2 ]
    then
		/usr/bin/nohup /usr/bin/php /home/huaji/www/adminapache/daemon/index.php b2c consumption >> /home/huaji/www/adminapache/daemon/application/logs/b2c_consumption.log 2>&1&
    fi
    #京东数据抓取
    PRO_NOW=`ps -ef | grep "jd consumption" | wc -l`

    if [ $PRO_NOW -lt 2 ]
    then
		/usr/bin/nohup /usr/bin/php /home/huaji/www/adminapache/daemon/index.php jd consumption >> /home/huaji/www/adminapache/daemon/application/logs/jdconsumption.log 2>&1&
    fi
	
    #淘宝数据抓取
    PRO_NOW=`ps aux | grep "taobao consumption" | wc -l`

    if [ $PRO_NOW -lt 2 ]
    then
		/usr/bin/nohup /usr/bin/php /home/huaji/www/adminapache/daemon/index.php taobao consumption >> /home/huaji/www/adminapache/daemon/application/logs/taobaoconsumption.log 2>&1&
    fi
	
	#订单推送
    PRO_NOW=`ps aux |grep "autopush consumption" | wc -l`

    if [ $PRO_NOW -lt 2 ]
    then
		/usr/bin/nohup /usr/bin/php /home/huaji/www/adminapache/daemon/index.php autopush consumption >> /home/huaji/www/adminapache/daemon/application/logs/autopushconsumption.log 2>&1&
    fi
done
exit 0

